package eg.com.itiga.business.user;

import eg.com.itiga.business.base.BaseServiceImpl;
import eg.com.itiga.business.exception.BusinessException;
import eg.com.itiga.domain.User;
import eg.com.itiga.repository.exception.DataException;
import eg.com.itiga.repository.factory.RepositoryFactory;
import eg.com.itiga.repository.user.UserDao;

public class UserServiceImpl extends BaseServiceImpl implements UserService {

	
	public User Login(User user) throws BusinessException {
		// TODO Auto-generated method stub
		UserDao userDao = null;
		User newUser = new User();
		try {
			userDao = RepositoryFactory.createUserDao();
			
			userDao.beginTransaction();
			newUser = userDao.getUserByCredential(user);
			userDao.commit();
			
		} catch(DataException ex) {
			userDao.rollback();
			//ex.printStackTrace();
			throw new BusinessException("Business Exception");
		}
		return newUser;

	}

}
